import os


def extract_specific_class(input_path='./dataset/wine/wine.data', output_path='./dataset/preprocessed/wine.data'):
    with open(input_path, 'r') as input_file:
        output_dir, _ = os.path.split(output_path)
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        with open(output_path, 'w') as output_file:
            line = input_file.readline()
            while line != '':
                # 取其中类别标签为一类和二类的白酒数据生成新的白酒数据
                if line[0] == '1' or line[0] == '2':
                    output_file.write(line)
                line = input_file.readline()
                print(line[0])


if __name__ == '__main__':
    extract_specific_class()
